package com.itbaizhan.springsecuritydemo1.service;

import org.springframework.context.annotation.Bean;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

public class MyUsersDetaliService {
    //进行内存认证
    @Bean
    public UserDetailsService userDetailsService (){
        InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
        //添加用户
        UserDetails user1 = User.withUsername("sxt").password("123").authorities("admin").build();
        UserDetails user2 = User.withUsername("itbz").password("456").authorities("admin").build();
        //创建用户
        manager.createUser(user1);
        manager.createUser(user2);
        
        return manager;
    }
}
